package com.zjxmyq.authorization.service;

import com.zjxmyq.authorization.domain.User;
import com.zjxmyq.authorization.mapper.UserMapper;
import com.zjxmyq.jwtmanage.utils.JwtTokenUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class LoginService {

//    @DubboReference
//    ReportService reportService;
    @Autowired
    UserMapper userMapper;
    @Resource
    private JwtTokenUtil jwtTokenUtil;
    public String testLogin(){
        User user = new User();
        user.setId(1);
        user.setName("xujf");
        // 通过 jwtTokenUtil 生成 JWT 令牌和刷新令牌
        Map<String, Object> tokenMap = jwtTokenUtil
                .generateTokenAndRefreshToken(String.valueOf(user.getId()), user.getName());
//        return reportService.testDubbo();
        return tokenMap.toString();
    }


    public String testAuth(User user){
        int res = userMapper.insert(user);
        log.info("database insert row :{}",res);
        return "success";
    }

}
